<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
      <#include "/common/elibs.html">
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
  </head>
  <script>
  </script><body>
    <div class="x-body">
        <form class="layui-form">
            <div class="layui-form-item">
                <input type="hidden" id="parent" name="parent" value="${id}">
                <label for="name" class="layui-form-label">
                    <span class="x-red">*</span>文件名称
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="name" name="name" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input" >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>


            <div class="layui-form-item">
                <label for="idxSysFiles" class="layui-form-label">
                    <span class="x-red">*</span>文件名称
                </label>
                <div class="layui-input-inline">
                    <input type="hidden" id="idxSysFiles" name="idxSysFiles"  >
                    <button type="button" class="layui-btn" id="upload">
                        <i class="layui-icon">&#xe67c;</i>上传文件
                    </button><script>
                    layui.use('upload', function(){
                        var upload = layui.upload;//执行实例
                        var uploadInst = upload.render({
                            elem: '#upload' //绑定元素
                            ,url: path+'/pc/upload/uploadFile' //上传接口
                            ,accept: 'file' //允许上传的文件类型
                            ,exts: 'pdf|docx|doc|xls|xlsx' //允许上传的文件后缀
                            ,done: function(res){
                                //上传完毕回调
                                $("#idxSysFiles").val(res.data.idSysFiles);
                            }
                            ,error: function(){
                                //请求异常回调
                            }
                        });
                    });
                </script>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="name" class="layui-form-label">
                </label>
                <button  class="layui-btn" lay-filter="add" lay-submit="">
                    提交
                </button>
            </div>
      </form>
    </div>
    <script>
        layui.use(['form','layer'], function(){
            $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer, layedit = layui.layedit;
          //自定义验证规则
          form.verify({
//            ,pass: [/(.+){6,12}$/, '密码必须6到12位']
            /*,repass: function(value){
                if($('#L_pass').val()!=$('#L_repass').val()){
                    return '两次密码不一致';
                }
            }*/
          });
          //监听提交
          form.on('submit(add)', function(t){
            var params = {
                //tcaDescribe : layui.layedit.getContent(index),
                "name" : $("#name").val(),
                "parent" : $("#parent").val(),
                "sort" : 0,
                "type" : 1,
                "idxSysFiles" : $("#idxSysFiles").val()
              }
            if(true){
                ajaxFun('post','/pc/fileCabinet/addFileInfo',params,function(data){
                    if(data.code != 0){
                        alertFun(data);
                    }else{
                        window.location.href= path + "/modules/fileCabinet/list.html";
                        console.log("success !");
                    }
                })
            }
            return false;
          });});
    </script></body></html>